// 封装专门处理时间的方法
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import 'dayjs/locale/zh'

export const timeAgo = (targetTime) => {
    dayjs.extend(relativeTime)
    dayjs.locale('zh')
    const a = dayjs()
    const b = dayjs(targetTime)
    return a.to(b)
}

export const formatDate = (dateObj) => {
    return dayjs(dateObj).format('YYYY-MM-DD')
}